//package com.hs.framework.loading;
//
//import android.content.Context;
//import android.graphics.drawable.AnimationDrawable;
//import android.util.AttributeSet;
//import android.view.View;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import androidx.annotation.ColorInt;
//import androidx.annotation.NonNull;
//import androidx.annotation.Nullable;
//import com.scwang.smart.refresh.layout.api.RefreshHeader;
//import com.scwang.smart.refresh.layout.api.RefreshKernel;
//import com.scwang.smart.refresh.layout.api.RefreshLayout;
//import com.scwang.smart.refresh.layout.constant.RefreshState;
//import com.scwang.smart.refresh.layout.constant.SpinnerStyle;
//
///**
// * SmartRefreshLayout 的自定义下拉刷新 Header
// */
////public class CustomRefreshHeader extends LinearLayout implements RefreshHeader {
////
////    private ImageView mImage;
////    private LinearLayout mLl_root;
////    private AnimationDrawable pullDownAnim;
////    private AnimationDrawable refreshingAnim;
////
////    private boolean hasSetPullDownAnim = false;
////
////    public CustomRefreshHeader(Context context) {
////        this(context, null, 0);
////    }
////
////    public CustomRefreshHeader(Context context, @Nullable AttributeSet attrs) {
////        this(context, attrs, 0);
////    }
////
////    public CustomRefreshHeader(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
////        super(context, attrs, defStyleAttr);
////        View view = View.inflate(context, R.layout.layout_loading_header, this);
////        mImage = (ImageView) view.findViewById(R.id.ivLoad);
////        mLl_root = (LinearLayout) view.findViewById(R.id.ll_root);
////    }
////
////    @NonNull
////    @Override
////    public View getView() {
////        return this;
////    }
////
////    @Override
////    public SpinnerStyle getSpinnerStyle() {
////        return SpinnerStyle.Translate;
////    }
////
////    @Override
////    public void onStartAnimator(RefreshLayout layout, int height, int extendHeight) {
////
////    }
////
////    /**
////     * 状态改变时调用。在这里切换第三阶段的动画卖萌小人
////     *
////     * @param refreshLayout
////     * @param oldState
////     * @param newState
////     */
////    @Override
////    public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) {
////        switch (newState) {
////            case RefreshState.PullDownToRefresh: //下拉刷新开始。正在下拉还没松手时调用
////                //每次重新下拉时，将图片资源重置为小人的大脑袋
////                mImage.setImageResource(R.drawable.animation_loading_header);
////                break;
////            case RefreshState.Refreshing: //正在刷新。只调用一次
////                //状态切换为正在刷新状态时，设置图片资源为小人卖萌的动画并开始执行
////                mImage.setImageResource(R.drawable.animation_loading_header);
////                refreshingAnim = (AnimationDrawable) mImage.getDrawable();
////                refreshingAnim.start();
////                break;
////            case RefreshState.ReleaseToRefresh: //mHeaderText.setText("释放立即刷新");
////
////                break;
////        }
////    }
////
////    /**
////     * 动画结束后调用
////     */
////    @Override
////    public int onFinish(RefreshLayout layout, boolean success) {
////        // 结束动画
////        if (pullDownAnim != null && pullDownAnim.isRunning()) {
////            pullDownAnim.stop();
////        }
////        if (refreshingAnim != null && refreshingAnim.isRunning()) {
////            refreshingAnim.stop();
////        }
////        //重置状态
////        hasSetPullDownAnim = false;
////        return 0;
////    }
////
////    @Override
////    public void setPrimaryColors(int... colors) {
////
////    }
////
////    @Override
////    public void onInitialized(RefreshKernel kernel, int height, int extendHeight) {
////
////    }
////
////    @Override
////    public void onMoving(boolean isDragging, float percent, int offset, int height, int extendHeight) {
////        // 下拉的百分比小于100%时，不断调用 setScale 方法改变图片大小
////        if (percent < 1) {
//////            mImage.setScaleX(percent);
//////            mImage.setScaleY(percent);
////
////            //是否执行过翻跟头动画的标记
////            if (hasSetPullDownAnim) {
////                hasSetPullDownAnim = false;
////            }
////        }
////
////        //当下拉的高度达到Header高度100%时，开始加载正在下拉的初始动画，即翻跟头
////        if (percent >= 1.0) {
////            //因为这个方法是不停调用的，防止重复
////            if (!hasSetPullDownAnim) {
////                mImage.setImageResource(R.drawable.animation_loading_header);
////                pullDownAnim = (AnimationDrawable) mImage.getDrawable();
////                pullDownAnim.start();
////
////                hasSetPullDownAnim = true;
////            }
////        }
////    }
////
////    @Override
////    public void onReleased(@NonNull RefreshLayout refreshLayout, int height, int extendHeight) {
////
////    }
////
////    @Override
////    public void onHorizontalDrag(float percentX, int offsetX, int offsetMax) {
////
////    }
////
////    @Override
////    public boolean isSupportHorizontalDrag() {
////        return false;
////    }
////
////
////    public void setRefreshHeadBackgroundColor(@ColorInt int color) {
////        mLl_root.setBackgroundColor(color);
////    }
////}